package org.raymond.iworks.study.orders.common;

import org.raymond.iworks.commons.utils.RandomValueUtil;
import org.raymond.iworks.study.orders.entity.TProducts;

import java.math.BigDecimal;

public class RandomProduct {

    private RandomProduct(){}

    public TProducts build(){
        return TProducts.builder()
                .productName(randomProductname())
                .productUnitPrice(randomPrice())
                .build();
    }

    private String randomProductname(){
        return "随机商品-"+ RandomValueUtil.getStr(10, 11);
    }
    private BigDecimal randomPrice(){
        return new BigDecimal(RandomValueUtil.getDouble(10, 10000));
    }
    private static class InstanceHolder {
        private static final RandomProduct INSTANCE = new RandomProduct();
    }

    public static TProducts create(){
        return RandomProduct.InstanceHolder.INSTANCE.build();
    }
}
